﻿using SqlSugar;

namespace Api.Shared.Model.Web.Login
{
    ///<summary>
    ///会员表
    ///</summary>
    [SugarTable("sp_user")]
    public partial class User
    {
        /// <summary>
        /// Desc:自增id
        /// Default:
        /// Nullable:False
        /// </summary>           
        [SugarColumn(ColumnName = "user_id", IsPrimaryKey = true, IsIdentity = true)]
        public int UserId { get; set; }

        /// <summary>
        /// Desc:登录名
        /// Default:
        /// Nullable:False
        /// </summary>      
        [SugarColumn(ColumnName = "username")]
        public string UserName { get; set; }

        /// <summary>
        /// Desc:qq官方唯一编号信息
        /// Default:
        /// Nullable:True
        /// </summary>         
        [SugarColumn(ColumnName = "qq_open_id")]
        public string? QqOpenId { get; set; }

        /// <summary>
        /// Desc:登录密码
        /// Default:
        /// Nullable:False
        /// </summary>      
        [SugarColumn(ColumnName = "password")]
        public string Password { get; set; }

        /// <summary>
        /// Desc:邮箱
        /// Default:
        /// Nullable:False
        /// </summary>   
        [SugarColumn(ColumnName = "user_email")]
        public string? UserEmail { get; set; }

        /// <summary>
        /// Desc:新用户注册邮件激活唯一校验码
        /// Default:
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "user_email_code")]
        public string? UserEmailCode { get; set; }

        /// <summary>
        /// Desc:新用户是否已经通过邮箱激活帐号
        /// Default:否
        /// Nullable:True
        /// </summary>      
        [SugarColumn(ColumnName = "is_active")]
        public string? IsActive { get; set; }

        /// <summary>
        /// Desc:性别
        /// Default:男
        /// Nullable:False
        /// </summary>  
        [SugarColumn(ColumnName = "user_sex")]
        public string? UserSex { get; set; }

        /// <summary>
        /// Desc:qq
        /// Default:
        /// Nullable:False
        /// </summary>       
        [SugarColumn(ColumnName = "user_qq")]
        public string? UserQq { get; set; }

        /// <summary>
        /// Desc:手机
        /// Default:
        /// Nullable:False
        /// </summary>  
        [SugarColumn(ColumnName = "user_tel")]
        public string? UserTel { get; set; }

        /// <summary>
        /// Desc:学历
        /// Default:本科
        /// Nullable:False
        /// </summary>         
        [SugarColumn(ColumnName = "user_xueli")]
        public string? UserXueli { get; set; }

        /// <summary>
        /// Desc:爱好
        /// Default:
        /// Nullable:False
        /// </summary>       
        [SugarColumn(ColumnName = "user_hobby")]
        public string? UserHobby { get; set; }

        /// <summary>
        /// Desc:简介
        /// Default:
        /// Nullable:True
        /// </summary>   
        [SugarColumn(ColumnName = "user_introduce")]
        public string? UserIntroduce { get; set; }

        /// <summary>
        /// Desc:创建时间
        /// Default:
        /// Nullable:False
        /// </summary>       
        [SugarColumn(ColumnName = "create_time")]
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// Desc:修改时间
        /// Default:
        /// Nullable:False
        /// </summary>   
        [SugarColumn(ColumnName = "update_time")]
        public DateTime? UpdateTime { get; set; }

        [SugarColumn(ColumnName = "mg_state")]
        public bool? MgState { get; set; }

        [SugarColumn(ColumnName = "roleName")]
        public string? RoleName { get; set; } = string.Empty;


        private int? GetUserLeve()
        {
            Dictionary<string, int> roleMappings = new Dictionary<string, int>()
            {
                {  "管理员",1},
                {  "测试员",2},
                {  "操作员",3},
                {  "观察者",4},
            };

            if (!string.IsNullOrEmpty(RoleName) && roleMappings.ContainsKey(RoleName))
            {
                return roleMappings[RoleName];
            }
            else
            {
                return 0;
            }
        }

        //private string GetUserRoleName()
        //{
        //    Dictionary<int, string> roleMappings = new Dictionary<int, string>()
        //    {
        //        { 1, "管理员" },
        //        { 2, "测试员" },
        //        { 3, "操作员" },
        //        { 4, "观察者" },
        //    };
        //    if (UserLevel.HasValue && roleMappings.ContainsKey(UserLevel.Value))
        //    {
        //        return roleMappings[UserLevel.Value];
        //    }
        //    else
        //    {
        //        return string.Empty;
        //    }
        //}
    }
}
